#include "m_buildinsert.h"
#include "ui_m_buildinsert.h"

#include <QMessageBox>
#include <QSqlQuery>

M_buildInsert::M_buildInsert(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::M_buildInsert)
{
    ui->setupUi(this);
}

M_buildInsert::~M_buildInsert()
{
    delete ui;
}

void M_buildInsert::on_confirmBtn_accepted()
{
    QSqlQuery query;
    QString sid=ui->bidEdit->text();
    QString sname=ui->bmaxEdit->text();
    QString ssex=ui->bnowEdit->text();
    QString sphone=ui->bsexEdit->text();


    QString str=QString("insert into building values('%1','%2','%3','%4')").
            arg(sid).arg(sname).arg(ssex).arg(sphone);
    qDebug()<<str;

    if(query.exec(str)){
        QMessageBox::information(NULL,"tips","添加成功");
        this->close();
    }
    else QMessageBox::warning(NULL,"Error","添加失败，请检查是否有内容写错");
}


void M_buildInsert::on_confirmBtn_rejected()
{
    this->close();
}

